import { Global } from "@/Global";
import { HttpHelper } from "./HttpHelper";
export class SystemUsersHelper {
    private static users: any[];
    static init = async () => {
        try {
            if (Global.UserInfo.Token) {
                SystemUsersHelper.users = JSON.parse(await HttpHelper.get(`/Auth/GetUsers`, null));
                console.log("用户数量:", SystemUsersHelper.users.length);
            }
            else {
                window.setTimeout(SystemUsersHelper.init, 1000);
            }
        } catch (error) {
            window.setTimeout(SystemUsersHelper.init, 1000);
        }
    }

    static getAllUsers = () => SystemUsersHelper.users;

    static getUserName = (id: any) => {
        if (!SystemUsersHelper.users)
            return "";
        var item = SystemUsersHelper.users.find(x => x.id == id);
        if (!item)
            return "UID:" + id;
        return item.Name;
    }
}